#ifndef __APP_MODBUS_H_
#define __APP_MODBUS_H_
#include <modbus/modbus.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>
#include "log.h"


/**
 * @brief modbus 初始化 
 */
int app_modbus_init(char *dev_file_name);


/**
 * @brief 线圈读   电机当前的开关状态
 */
int app_modbus_readCoil(int slave_id, int start_address,  uint16_t reg_nums, uint8_t *buff);

/**
 * @brief 线圈写   操作电机的开关
 */
int app_modbus_writeCoil(int slave_id, int start_address,  uint16_t reg_nums, uint8_t *data);


/**
 * @brief 保持寄存器写   设置转速
 */
int app_modbus_writeHoldingRegister(int slave_id, int start_address,  uint16_t reg_nums, uint16_t *data);

/**
 * @brief 读取输入寄存器  获取当前转速
 */
int app_modbus_readInputRegister(int slave_id, int start_address,  uint16_t reg_nums, uint16_t *buff);


/**
 * @brief 销毁modbus
 */
void app_modbus_destroy(void);



#endif // __APP_MODBUS_H_
